package com.mate.cloud.pipeline.coderiver.controller;

import com.mate.cloud.common.response.BaseResponse;
import com.mate.cloud.common.web.controller.AdminBaseController;
import com.mate.cloud.pipeline.coderiver.constant.RedisConstans;
import com.mate.cloud.pipeline.coderiver.service.RedisPipelineService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@Tag(description = "user", name = "用户服务")
@RequestMapping("/user")
public class UserPipelineController extends AdminBaseController {


    @Resource
    private RedisPipelineService redisPipelineService;


    @GetMapping("/save/{num}")
    @Operation(summary = "批量保存")
    public BaseResponse save(@PathVariable Integer num) {
        redisPipelineService.batchUserPipeline(RedisConstans.USER_ID, num);
        return successCodeResponse();
    }


    @GetMapping("/batchInsert")
    @Operation(summary = "批量添加")
    public BaseResponse batchInsertWithPipeline(@RequestParam("prefix") String prefix, @RequestParam("count") int count) {
        ;
        return successBodyResponse(redisPipelineService.batchInsertWithPipeline(prefix, count));
    }


    @GetMapping("/add")
    @Operation(summary = "逐条插入")
    public BaseResponse add(@RequestParam("prefix") String prefix, @RequestParam("count") int count) {

        return successBodyResponse(redisPipelineService.batchInsertWithout(prefix, count));
    }

}
